import { downLoadXlsx } from '@/utils/downloadfile';
import request from '@/utils/request';

//获取目标统计分析菜单
export const getAnalysisTargetMenu = () => {
  return request({
    url: "/analysisTarget/getAnalysisTargetMenu",
    method: "get",
  });
};

// 空中目标=>距离范围 /analysisTarget/getDistanceRange
export const getDistanceRange = (params) => {
  const queryString = new URLSearchParams(params).toString();
  return request({
    url: "/analysisTarget/getDistanceRange?"+ queryString,
    method: "get",
    data: params
  });
};

// /analysisTarget/getAzimuthRange 空中目标=>方位范围
export const getAzimuthRange = (params) => {
  const queryString = new URLSearchParams(params).toString();
  return request({
    url: "/analysisTarget/getAzimuthRange?"+ queryString,
    method: "get",
    data: params
  });
};

// /analysisTarget/getDeviation 空中目标=>目标精度
export const getDeviation = (params) => {
  const queryString = new URLSearchParams(params).toString();
  return request({
    url: "/analysisTarget/getDeviation?"+ queryString,
    method: "get",
    data: params
  });
};

// /analysisTarget/getMinRadialSpeed  空中目标=>最小径向速度统计
export const getMinRadialSpeed = (params) => {
  const queryString = new URLSearchParams(params).toString();
  return request({
    url: "/analysisTarget/getMinRadialSpeed?"+ queryString,
    method: "get",
    data: params
  });
};

// /analysisTarget/getSystemAvailable 系统可用度统计
export const getSystemAvailable = (params) => {
  const queryString = new URLSearchParams(params).toString();
  return request({
    url: "/analysisTarget/getSystemAvailable?"+ queryString,
    method: "get",
    data: params
  });
};

// /analysisTarget/exportDistanceRange  导出距离范围统计
export function exportDistanceRange(params) {
  return downLoadXlsx(`/analysisTarget/exportDistanceRange`, { params }, `距离范围统计列表${new Date().getTime()}.xlsx`);
}

// /analysisTarget/exportDeviation  导出目标精度分析
export function exportDeviation(params) {
  return downLoadXlsx(`/analysisTarget/exportDeviation`, { params }, `目标精度分析列表${new Date().getTime()}.xlsx`);
}

// /analysisTarget/exportMinRadialSpeed 导出最小径向速度统计
export function exportMinRadialSpeed(params) {
  return downLoadXlsx(`/analysisTarget/exportMinRadialSpeed`, { params }, `最小径向速度统计列表${new Date().getTime()}.xlsx`);
}

// /analysisTarget/exportAzimuthRange 导出方位范围统计
export function exportAzimuthRange(params) {
  return downLoadXlsx(`/analysisTarget/exportAzimuthRange`, { params }, `方位范围统计列表${new Date().getTime()}.xlsx`);
}

// 数据接口列表  /dataConfig/listDataInterfaces
export const listDataInterfaces = (params) => {
  const queryString = new URLSearchParams(params).toString();
  return request({
    url: "/dataConfig/listDataInterfaces?"+ queryString,
    method: "get",
    data: params
  });
};

// /dataConfig/addDataInterface create数据接口
export async function addDataInterface(params) {
  return request(`/dataConfig/addDataInterface`, {
    data: params,
    method: 'POST',
  });
}

// /dataConfig/editDataInterface update数据接口
export async function editDataInterface(params) {
  return request(`/dataConfig/editDataInterface`, {
    data: params,
    method: 'PUT',
  });
}

// /dataConfig/removeDataInterface/{ids}
export async function removeDataInterface(params) {
  return request(`/dataConfig/removeDataInterface/${params}`, {
    method: 'DELETE',
  });
}

// /dataConfig/listDataTypes 数据类型列表
export const listDataTypes = (params) => {
  const queryString = new URLSearchParams(params).toString();
  return request({
    url: "/dataConfig/listDataTypes?"+ queryString,
    method: "get",
    data: params
  });
};

// /dataConfig/startOrStop/{id}  数据类型状态修改
export const changeTypeStatus = (id) => {
  return request({
    url: "/dataConfig/startOrStop/"+ id,
    method: "get",
  });
};

// /dataConfig/listAllAddressPort 获取数据接口
export const listAllAddressPort = () => {
  return request({
    url: "/dataConfig/listAllAddressPort",
    method: "get",
  });
};

// /dataConfig/addDataType create数据类型
export async function addDataType(params) {
  return request(`/dataConfig/addDataType`, {
    data: params,
    method: 'POST',
  });
}

// /dataConfig/editDataType update数据类型
export async function updateDataType(params) {
  return request(`/dataConfig/editDataType`, {
    data: params,
    method: 'PUT',
  });
}

// /dataConfig/removeDataType/{ids} delete数据类型
export async function removeDataType(params) {
  return request(`/dataConfig/removeDataType/${params}`, {
    method: 'DELETE',
  });
}

